package com.example.getsystempropdemo;

import android.os.RemoteException;
import android.os.SystemProperties;
import android.util.Log;

import java.text.SimpleDateFormat;
import java.util.Date;

public class GetSystemPropImpl extends IGetSystemPropInterface.Stub {
    private static final String TAG = "GetSystemPropImpl";

    private String mUserDefind = null;

    @Override
    public String getDeviceVersion() throws RemoteException {
        return SystemProperties.get("ro.product.model");
    }

    @Override
    public String getAndroidVersion() throws RemoteException {
        return SystemProperties.get("ro.build.version.release");
    }

    @Override
    public String getSystemVersion() throws RemoteException {
        return SystemProperties.get("ro.build.display.id");
    }

    @Override
    public String getCompileTime() throws RemoteException {
        return SystemProperties.get("ro.build.date");
    }

    @Override
    public String getCurrentTime() throws RemoteException {
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年-MM月dd日-HH时mm分ss秒 E");

        return dateFormat.format(date);
    }

    @Override
    public String getUserDefined() throws RemoteException {
        return mUserDefind;
    }

    @Override
    public String setInfo(String info) throws RemoteException {
        if (info != null) {
            mUserDefind = info;
        }
        return null;
    }

    private void DEBUG(String info) {
        Log.d(TAG, info);
    }
}
